<?php

use yii\db\Migration;

class m180403_083247_create_customer_student extends Migration
{
//    private function createDbs(){
//        $dbs = [];
//        $dbs_info =\Yii::$app->params['db'];
//        foreach($dbs_info as $k=>$v){
//            $dbs[$k] = \Yii::createObject($v);
//        }
//        return $dbs;
//    }
    public function safeUp()
    {
        $this->createTable('{{%customer_student_loction}}',[
            'customer_id' => $this->integer()->defaultValue(0)->comment('会员'),
            'student_id' => $this->integer()->defaultValue(0)->comment('学员id'),
        ]);
        $this->createTable('{{%student_scholarship}}',[
            'student_id' => $this->integer()->defaultValue(0)->comment('学员id'),
            'scholarship' => $this->decimal(10,2)->defaultValue(0)->comment('奖学金'),
            'deposit' => $this->decimal(10,2)->defaultValue(0)->comment('保证金金额'),
        ]);
        $this->addColumn('{{%account_record}}', 'student_id', $this->integer()->defaultValue(0)->comment('学员id'));
        $this->addColumn('{{%deposit_log}}', 'student_id', $this->integer()->defaultValue(0)->comment('学员id'));
    }

    public function safeDown()
    {
        $this->dropTable('{{%customer_student_loction}}');
        $this->dropTable('{{%student_scholarship}}');
        $this->dropColumn('{{%account_record}}', 'student_id');
        $this->dropColumn('{{%deposit_log}}', 'student_id');
    }
}
